from django.db import models
from users.models import User

class Report(models.Model):
    """报告模型"""
    user = models.ForeignKey(
        User,
        on_delete=models.CASCADE,
        verbose_name='创建用户',
        related_name='reports'
    )
    title = models.CharField('报告标题', max_length=255)
    content = models.TextField('报告内容')
    workflow_name = models.IntegerField(
        choices=[(1, '阶段总结'), (2, '产业报告')],
        verbose_name='工作流名称'
    )
    report_type = models.IntegerField(
        choices=[(0, '无'), (1, '月度'), (2, '季度'), (3, '年度')],
        default=0,
        verbose_name='报告类型'
    )
    report_style = models.IntegerField(
        choices=[(0, '无'), (1, '决策'), (2, '创新'), (3, '科研')],
        default=0,
        verbose_name='报告风格'
    )
    industry = models.CharField('关联产业', max_length=100)
    created_at = models.DateTimeField('创建时间', auto_now_add=True)
    updated_at = models.DateTimeField('更新时间', auto_now=True)

    class Meta:
        db_table = 'reports'
        verbose_name = '报告'
        verbose_name_plural = verbose_name
        ordering = ['-created_at']
    
    def __str__(self):
        return self.title
    
    @property
    def workflow_name_display(self):
        """获取工作流名称的显示值"""
        return self.get_workflow_name_display() 